﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;
using WebCore.Helpers;
using DomainModel.Concrete;

namespace WebCore.Services
{
    public class RateService
    {
        public static bool IsUserRated(HttpContext context, int eventID)
        {
            // make sure user is authenticated
            if (!context.User.Identity.IsAuthenticated)
                return false;

            int userID = UserHelper.GetUserIDFromIdentityTicket((FormsIdentity)context.User.Identity);

            if (userID == 0)
                return false;

            var ratesReposotry = new RatesRepository();

            var item = ratesReposotry.GetByEventIDAndUserID(eventID, userID);

            if (item == null)
                return false;

            return true;
        }
    }
}
